﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TtgProject.DAO;

namespace TtgProject.LOGIN
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string userName = txtUser.Text;
            string passWord = txtPassword.Text;

            if (!String.IsNullOrEmpty(userName) && !String.IsNullOrEmpty(passWord))
            {
                TTGEntities ttgEntity = new TTGEntities();
                USER_TABLE usTable = ttgEntity.USER_TABLE.SingleOrDefault(u => u.USER_ID.Equals(userName) && u.USER_PASSWORD.Equals(passWord));
                if (usTable != null)
                {
                    Session.Add("User", userName);
                    Response.Redirect("~/Default.aspx");
                }
                else
                {
                    lblMessage.Text = "Invalid User Or Password...Re-enter";
                }
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }
    }
}